<div class="panel panel-primary">
  <a data-toggle="collapse" data-parent="#accordion2" href="#collapse5" aria-expanded="true" aria-controls="collapse5">
    <div class="panel-heading">
      <h3 class="panel-title">广告推广&nbsp;<span class="caret"></span></h3>
    </div>
  </a>
  <div id="collapse5" class="panel-collapse collapse in" role="tabpanel">
    <div class="panel-body">
      <div class="row">
        {php $options = array('on'=>'开启', 'off'=>'关闭');}
        {if empty($item['adv_on_off'])}
          {if empty($adv_cache['adv_on_off']) }
            {php $item['adv_on_off']='off';}
          {else}
            {php $item['adv_on_off']=$adv_cache['adv_on_off'];}
          {/if}
        {/if}
        {if empty($id) and empty($adv_cache['weid'])}
          {php $adv_cache['adv_top'] = htmlspecialchars('<p style="color:red;display:block;width:100%;margin:auto;text-align:center;background-color:rgba(0,0,0,0.8);">顶部广告，支持html, 支持图片, 支持js脚本</p>'); }
          {php $adv_cache['adv_status'] = "<p>阅读read_count 分享朋友圈送share_credit积分  好友阅读送click_credit积分"; }
          {php $adv_cache['adv_bottom'] = htmlspecialchars('<div style="height:100px"></div><div style="position:fixed;bottom:0px;width:100%;background-color:rgba(0,0,0,0.8);"><img src="http://www.yz929.cn/wp-content/uploads/2015/06/活动banner.jpg" /></div>');}
        {/if}

        <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">广告开关</label>
        {loop $options $o=>$v}
        <div class="radio col-xs-2">
          <label>
            <input type="radio" name="adv_on_off" value="{$o}" {if $o==$item['adv_on_off']}checked{/if}>
            {$v}
          </label>
        </div>
        {/loop}
      </div>
      <br/>

      <div class="panel-body row-adv">
        <div class="form-group">
          <div class="col-sm-12">
            <textarea style="height:300px; width:100%" rows="10" class="richtext" name="adv_top">{if empty($item['adv_top'])}{$adv_cache['adv_top']}{else}{$item['adv_top']}{/if}</textarea>
            <span class='help-block'>顶部广告代码 ↑ <br> <br></span>
          </div>
          <div class="col-sm-12">
            <textarea style="height:300px; width:100%" rows="10" class="richtext" name="adv_status">{if empty($item['adv_status'])}{$adv_cache['adv_status']}{else}{$item['adv_status']}{/if}</textarea>
            <span class='help-block'>标题下方自定义信息↑ </span>
            <span class='help-block'>
              HTML中可以使用如下标签，显示时自动替换成实际的数字/内容：分享积分share_credit，点击积分click_credit，文章可送积分max_credit
              来源source, 作者author, 标题title, 阅读数read_count
              <br>
              <br>
            </span>
          </div>
          <div class="col-sm-12">
            <textarea style="height:300px; width:100%" rows="10" class="richtext" name="adv_bottom">{if empty($item['adv_bottom'])}{$adv_cache['adv_bottom']}{else}{$item['adv_bottom']}{/if}</textarea>
            <span class='help-block'>底部自定义信息 ↑ <br> <br> </span>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

<script>
  $(function(){
    {if $item['adv_on_off']=='off'}
    $(".row-adv").hide();
    {/if}
    $("input[name='adv_on_off']").on('click', function() {
      if ($(this).val() == 'on') {
        $(".row-adv").show();
        } else {
        $(".row-adv").hide();
      }
    });
  });
</script>
